<!DOCTYPE html>
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  <meta name="description" content="刘清政">
  <meta name="keyword" content="hexo-theme">
  
    <link rel="shortcut icon" href="/css/images/logo.png">
  
  <title>
    
      linux/入门到精通/07-Linux基本权限 | Justin-刘清政的博客
    
  </title>
  <link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/tomorrow.min.css" rel="stylesheet">
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/css/plugins/gitment.css">

  
  <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/geopattern/1.2.3/js/geopattern.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>
  
    
<script src="/js/qrious.js"></script>

  
  
    
<script src="/js/gitment.js"></script>

  
  

  
<meta name="generator" content="Hexo 4.2.0"></head>
<div class="wechat-share">
  <img src="/css/images/logo.png" />
</div>

  <body>
    <header class="header fixed-header">
  <div class="header-container">
    <a class="home-link" href="/">
      <div class="logo"></div>
      <span>Justin-刘清政的博客</span>
    </a>
    <ul class="right-list">
      
        <li class="list-item">
          
            <a href="/" class="item-link">主页</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/tags/" class="item-link">标签</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/archives/" class="item-link">归档</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/about/" class="item-link">关于我</a>
          
        </li>
      
    </ul>
    <div class="menu">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </div>
    <div class="menu-mask">
      <ul class="menu-list">
        
          <li class="menu-item">
            
              <a href="/" class="menu-link">主页</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/tags/" class="menu-link">标签</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/archives/" class="menu-link">归档</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/about/" class="menu-link">关于我</a>
            
          </li>
        
      </ul>
    </div>
  </div>
</header>

    <div id="article-banner">
  <h2>linux/入门到精通/07-Linux基本权限</h2>



  <p class="post-date">2020-07-06</p>
    <!-- 不蒜子统计 -->
    <span id="busuanzi_container_page_pv" style='display:none' class="">
        <i class="icon-smile icon"></i> 阅读数：<span id="busuanzi_value_page_pv"></span>次
    </span>
  <div class="arrow-down">
    <a href="javascript:;"></a>
  </div>
</div>
<main class="app-body flex-box">
  <!-- Article START -->
  <article class="post-article">
    <section class="markdown-content"><h2 id="1-权限基本概述"><a href="#1-权限基本概述" class="headerlink" title="1.权限基本概述"></a>1.权限基本概述</h2><h3 id="1-什么是权限？"><a href="#1-什么是权限？" class="headerlink" title="1.什么是权限？"></a>1.什么是权限？</h3><p>我们可以把它理解为操作系统对用户能够执行的功能所设立的限制，主要用于约束用户能对系统所做的操作，以及内容访问的范围，或者说，权限是指某个特定的用户具有特定的系统资源使用权力。</p>
<h3 id="2-为什么要有权限？"><a href="#2-为什么要有权限？" class="headerlink" title="2.为什么要有权限？"></a>2.为什么要有权限？</h3><p>因为系统中不可能只存在一个root用户，一定会存在多个用户，为了保护每个登陆用户的隐私和工作环境，所以就有了权限。(比如三个租客合租同一个房子，a租客要使用b租客的肥皂，那这个事情？？)</p>
<h3 id="3-权限与用户之间的关系？"><a href="#3-权限与用户之间的关系？" class="headerlink" title="3.权限与用户之间的关系？"></a>3.权限与用户之间的关系？</h3><p>在Linux系统中，针对文件定义了三种身份，分别是属主(owner)、属组(group)、其他人(others)，每一种身份又对应三种权限，分别是可读(readable)、可写(writable)、可执行(excutable)。</p>
<p><img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1ghu6xvd061j30l208lwfe.jpg" alt="img"><br>用户对文件资源，有三种角色ugo，当一个用户访问文件流程如下</p>
<p>1) 判断用户是否为文件所有者，如果是则按所有者的权限进行访问<br>2) 判断用户是否为文件所有组成员，如果是则按组的权限进行访问<br>3) 如果不是所有者，也不是该文件所属组，则按匿名权限进行访问</p>
<h3 id="4-权限中的rwx分别代表什么含义？"><a href="#4-权限中的rwx分别代表什么含义？" class="headerlink" title="4.权限中的rwx分别代表什么含义？"></a>4.权限中的rwx分别代表什么含义？</h3><p>当我们使用ls -l查看一个文件的详细属性时，能看到每个文件都有一个9位基本权限位，比如: <code>rwxr-xr-x</code>其中每三位字符为一组，分别表示属主权限位，属组权限位，匿名权限位。<br>linux中基本权限位则是使用这9位字符来表示，主要控制文件属主(User)、属组(Group)、其他用户(Other)</p>
<table>
<thead>
<tr>
<th align="left">字母</th>
<th align="left">含义</th>
<th align="left">对应权限</th>
</tr>
</thead>
<tbody><tr>
<td align="left">r(read)</td>
<td align="left">读取权限</td>
<td align="left">4</td>
</tr>
<tr>
<td align="left">w(write)</td>
<td align="left">写入权限</td>
<td align="left">2</td>
</tr>
<tr>
<td align="left">x(execute)</td>
<td align="left">执行权限</td>
<td align="left">1</td>
</tr>
<tr>
<td align="left">-(没有权限)</td>
<td align="left">没有权限</td>
<td align="left">0</td>
</tr>
</tbody></table>
<p>PS: 如果权限位不可读、不可写、不可执行，则全部使用-作为占位符表示。</p>
<h2 id="2-权限设置示例"><a href="#2-权限设置示例" class="headerlink" title="2.权限设置示例"></a>2.权限设置示例</h2><p>文件示例: rwxrw-r– alice hr file1.txt<br>Q1: alice对file1文件拥有什么权限?<br>Q2: jack 对 file1.txt 文件有什么权限? 前提:jack 属于 hr 组<br>Q3: tom 对 file1.txt 文件有什么权限?</p>
<h3 id="1-为什么要设定权限，我们又如何修改一个文件的权限"><a href="#1-为什么要设定权限，我们又如何修改一个文件的权限" class="headerlink" title="1.为什么要设定权限，我们又如何修改一个文件的权限?"></a>1.为什么要设定权限，我们又如何修改一个文件的权限?</h3><p>Q1: 为什么要设定权限，可以赋于某个用户或组 – 能够以何种方式 – 访问某个文件<br>Q2: Linux下使用chmod命令来变更权限，root用户可以变更所有文件的权限，而普通用户仅能变更属于自己的文件。</p>
<h3 id="2-使用chmod设定权限示例"><a href="#2-使用chmod设定权限示例" class="headerlink" title="2.使用chmod设定权限示例"></a>2.使用chmod设定权限示例</h3><p>方式一: user group other</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">[root@bgx ~]<span class="comment"># touch file                    #创建文件</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chmod a=rwx file              #给所有人添加读写执行权限</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chmod a=-rwx file             #取消所有的权限</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chmod u=rwx,g=rw,o=- file     #属主读写执行，属组读写，其他人无权限</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chmod ug=rwx,o=r file         #属主属组读写执行，其他人读权限</span></span><br><span class="line">[root@bgx ~]<span class="comment"># ll file</span></span><br><span class="line">-rwxrw-r-- 1 root root 0 Apr 13 03:29 file</span><br></pre></td></tr></table></figure>

<p>方式二、number</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#选项:  -R递归修改</span></span><br><span class="line">[root@bgx ~]<span class="comment"># touch file</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chmod 644 file</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chmod 600 file</span></span><br><span class="line">[root@bgx ~]<span class="comment"># ll file</span></span><br><span class="line">-rw------- 1 root root 0 Apr 13 03:29 file</span><br><span class="line"></span><br><span class="line"><span class="comment">#针对目录设定权限</span></span><br><span class="line">[root@bgx ~]<span class="comment"># mkdir dir</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chmod 777 dir/    #修改目录允许所有人访问</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chmod -R 755 dir/ #修改目录及子目录权限</span></span><br><span class="line">[root@bgx ~]<span class="comment"># ll -d dir/</span></span><br><span class="line">drwxr-xr-x 2 root root 6 Apr 13 03:34 dir/</span><br></pre></td></tr></table></figure>

<h3 id="3-权限设置案例"><a href="#3-权限设置案例" class="headerlink" title="3.权限设置案例"></a>3.权限设置案例</h3><p>针对 hr 部门的访问目录/home/hr 设置权限，要求如下:<br>1.root 用户和 hr 组的员工可以读、写、执行<br>2.其他用户没有任何权限</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">[root@bgx ~]<span class="comment"># groupadd hr</span></span><br><span class="line">[root@bgx ~]<span class="comment"># useradd hr01 -G hr</span></span><br><span class="line">[root@bgx ~]<span class="comment"># useradd hr02 -G hr</span></span><br><span class="line">[root@bgx ~]<span class="comment"># mkdir /home/hr</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chgrp hr /home/hr</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chmod 770 /home/hr</span></span><br><span class="line">[root@bgx ~]<span class="comment"># ll -d /home/hr</span></span><br><span class="line">drwxrwx--- 2 root hr 6 Apr 13 03:26 /home/hr</span><br></pre></td></tr></table></figure>

<h2 id="3-权限设置案例-1"><a href="#3-权限设置案例-1" class="headerlink" title="3.权限设置案例"></a>3.权限设置案例</h2><p>在Linux中权限对文件和对目录的影响是有不同区别的。</p>
<table>
<thead>
<tr>
<th align="left">权限</th>
<th align="left">对文件的影响</th>
<th align="left">对目录的影响</th>
</tr>
</thead>
<tbody><tr>
<td align="left">读取权限（r）</td>
<td align="left">具有读取阅读文件内容权限</td>
<td align="left">具有浏览目录及子目录</td>
</tr>
<tr>
<td align="left">写入权限（w）</td>
<td align="left">具有新增、修改文件内容的权限</td>
<td align="left">具有增加和删除目录内文件</td>
</tr>
<tr>
<td align="left">执行权限（x）</td>
<td align="left">具有执行文件的权限</td>
<td align="left">具有访问目录的内容(取决于目录中文件权限)</td>
</tr>
</tbody></table>
<p>文件权限实验案例:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#1.新建文件，并添加内容至文件中，默认文件匿名用户仅有读权限</span></span><br><span class="line">[root@lqz ~]<span class="comment"># echo "date" &gt; filename</span></span><br><span class="line">[root@lqz ~]<span class="comment"># ll filename</span></span><br><span class="line">-rw-r--r-- 1 root root 5 Jan 24 08:24 filename</span><br><span class="line"></span><br><span class="line"><span class="comment">#2.切换bgx普通用户</span></span><br><span class="line">[root@lqz ~]<span class="comment"># su - bgx</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#3.对文件拥有读取的权限，但bgx用户对文件没有执行和删除的权限</span></span><br><span class="line">[bgx@lqz ~]$ cat  /root/filename</span><br><span class="line">date</span><br><span class="line"></span><br><span class="line"><span class="comment">#4.使用root增加x执行权限</span></span><br><span class="line">[root@lqz ~]<span class="comment"># chmod o+x /root/filename</span></span><br><span class="line">[root@lqz ~]<span class="comment"># ll /root/filename</span></span><br><span class="line">-rw-r--r-x 1 root root 5 Jan 24 08:24 /root/filename</span><br><span class="line"></span><br><span class="line"><span class="comment">#5.测试x权限是否真的能执行该文件</span></span><br><span class="line">[bgx@lqz ~]$ /root/filename</span><br><span class="line">Wed Jan 24 08:28:34 EST 2018</span><br><span class="line"></span><br><span class="line"><span class="comment">#6.增加w执行权限</span></span><br><span class="line">[root@lqz ~]<span class="comment"># chmod o+w /root/filename</span></span><br><span class="line">[root@lqz ~]<span class="comment"># ll /root/filename</span></span><br><span class="line">-rw-r--rwx 1 root root 5 Jan 24 08:24 /root/filename</span><br><span class="line"></span><br><span class="line"><span class="comment">#7.测试执行权限</span></span><br><span class="line">[bgx@lqz ~]$ vim /root/filename</span><br></pre></td></tr></table></figure>

<p>PS: 总结rwx对文件的影响<br>读取权限（r）具有读取阅读文件内容权限<br>1.只能使用查看类命令cat、head、tail、less、more</p>
<p>写入权限（w）具有新增、修改文件内容的权限<br>1.使用vim编辑会提示权限拒绝, 但可强制保存,会覆盖文件的所有内容<br>2.使用echo命令重定向的方式可以往文件内写入数据,&gt;&gt;可以进行追加<br>3.不能删除文件,因为删除文件看的不是文件的属性,需要看上级目录是否有w的权限</p>
<p>执行权限（x）具有执行文件的权限<br>1.执行权限什么用都没有<br>2.如果普通用户需要执行文件,需要配合r权限</p>
<p>目录权限实验案例:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#示例1: 创建目录，并在该目录下创建文件，匿名用户对目录没有w权限，对文件有777权限 </span></span><br><span class="line">[root@lqz ~]<span class="comment"># mkdir /dirname</span></span><br><span class="line">[root@lqz ~]<span class="comment"># echo "test" &gt;&gt; /dirname/filename</span></span><br><span class="line">[root@lqz ~]<span class="comment"># chmod 777 /dirname/filename</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#普通用户验证权限，能正常查看，但无法删除[奇怪]</span></span><br><span class="line">[bgx@lqz ~]$ cat /dirname/filename</span><br><span class="line"><span class="built_in">test</span></span><br><span class="line">[bgx@lqz ~]$ rm -f /dirname/filename</span><br><span class="line">rm: cannot remove ‘/dirname/filename’: Permission denied</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#示例2: 设置目录777权限，相当于匿名用户对目录有w权限，对文件没有任何权限</span></span><br><span class="line">[root@lqz ~]<span class="comment"># chmod 777 /dirname/</span></span><br><span class="line">[root@lqz ~]<span class="comment"># chmod 000 /dirname/filename</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#普通用户验证权限</span></span><br><span class="line">[bgx@lqz ~]$ cat /dirname/filename</span><br><span class="line">cat: /dirname/filename: Permission denied</span><br><span class="line">[bgx@lqz ~]$ rm -f /dirname/filename</span><br><span class="line">[bgx@lqz ~]$ touch /dirname/filename_2</span><br></pre></td></tr></table></figure>

<p>PS: 总结rwx对目录的影响<br>读取权限（r），如果目录只有r权限: 具有浏览目录及子目录权限<br>1.可以使用ls命令浏览目录及子目录， 但同时也会提示权限拒绝<br>2.使用ls -l命令浏览目录及子目录，文件属性会带问号，并且只能看到文件名<br>总结: 目录只有r权限，仅仅只能浏览内的文件名，无其他操作权限</p>
<p>写入权限（w），如果目录只有w权限: 具有增加、删除或修改目录内文件名权限(需要x权限配合)<br>PS: 如果目录有w权限, 可以在目录内创建文件, 删除文件(跟文件本身权限无关)<br>不能进入目录、不能复制目录、不能删除目录、不能移动目录</p>
<p>执行权限（x），如果目录只有x权限<br>1.只能进入目录<br>2.不能浏览、复制、移动、删除</p>
<p>Linux权限总结与注意事项<br>文件r权限, 只给用户查看,无其他操作<br>文件rw权限, 可以查看和编辑文件内容<br>文件rx权限, 允许查看和执行文件、但不能修改文件—–&gt;PASS<br>文件rwx权限, 能读,能写,能执行,但不能删除,因为删除需要看上级目录的权限有没有w—–&gt;PASS<br>目录rx权限, 允许浏览目录内文件以及子目录、并允许在目录内新建文件, 不允许创建、删除文件和目录<br>目录wx权限, 能进入目录,能删除内容,能写入内容,但就是无法使用ls cat这样的命令—–&gt;PASS<br>目录rw权限, 能看,能写,但无法进入目录—–&gt;PASS<br>PS: 文件的 x权限小心给予，目录的 w权限小心给予。<br>PS: 文件通常设定的权限是644,目录设定的权限是755<br>PS: 控制目录权限755, 如果有普通用户需要操作目录里面的文件，在来看文件的权限</p>
<h2 id="4-属主属组设置"><a href="#4-属主属组设置" class="headerlink" title="4.属主属组设置"></a>4.属主属组设置</h2><p>变更文件属主和属组的意义？<br>比如: 我现在手里有多套房，希望出售其中的A房进行变现，那么我会考虑将A房过户给金主，过户成功后A房就属于金主了，那么此时A房的拥有者就属于金主而不再属于我。<br><img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1ghu6y1texfj30mc0g4dhf.jpg" alt="img"></p>
<p>在Linux中如何变更一个文件或者一个资源的属主和属组呢，可以使用chown、chgrp命令实现。<br>chown能设置属主和属组，chgrp仅能设置属组。（所以用哪个你懂的）</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#chown 更改属主以及属组 -R：递归修改</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#准备环境，创建文件和目录</span></span><br><span class="line">[root@bgx ~]<span class="comment"># mkdir dir/test1 &amp;&amp; touch dir/file</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#示例1: 修改所属主为bin</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chown bin dir/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#示例2: 修改所属组为adm</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chown .adm dir/</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#示例3: 递归修改目录及目录下的所有文件属主和属组</span></span><br><span class="line">[root@bgx ~]<span class="comment"># chown -R root.root dir/</span></span><br></pre></td></tr></table></figure></section>
    <!-- Tags START -->
    
    <!-- Tags END -->
    <!-- NAV START -->
    
  <div class="nav-container">
    <!-- reverse left and right to put prev and next in a more logic postition -->
    
      <a class="nav-left" href="/linux/%E5%85%A5%E9%97%A8%E5%88%B0%E7%B2%BE%E9%80%9A/06-Linux%E7%94%A8%E6%88%B7%E7%AE%A1%E7%90%86/">
        <span class="nav-arrow">← </span>
        
          linux/入门到精通/06-Linux用户管理
        
      </a>
    
    
      <a class="nav-right" href="/linux/%E5%85%A5%E9%97%A8%E5%88%B0%E7%B2%BE%E9%80%9A/08-Linux%E7%89%B9%E6%AE%8A%E6%9D%83%E9%99%90/">
        
          linux/入门到精通/08-Linux特殊权限
        
        <span class="nav-arrow"> →</span>
      </a>
    
  </div>

    <!-- NAV END -->
    <!-- 打赏 START -->
    
      <div class="money-like">
        <div class="reward-btn">
          赏
          <span class="money-code">
            <span class="alipay-code">
              <div class="code-image"></div>
              <b>使用支付宝打赏</b>
            </span>
            <span class="wechat-code">
              <div class="code-image"></div>
              <b>使用微信打赏</b>
            </span>
          </span>
        </div>
        <p class="notice">点击上方按钮,请我喝杯咖啡！</p>
      </div>
    
    <!-- 打赏 END -->
    <!-- 二维码 START -->
    
      <div class="qrcode">
        <canvas id="share-qrcode"></canvas>
        <p class="notice">扫描二维码，分享此文章</p>
      </div>
    
    <!-- 二维码 END -->
    
      <!-- Gitment START -->
      <div id="comments"></div>
      <!-- Gitment END -->
    
  </article>
  <!-- Article END -->
  <!-- Catalog START -->
  
    <aside class="catalog-container">
  <div class="toc-main">
  <!-- 不蒜子统计 -->
    <strong class="toc-title">目录</strong>
    
      <ol class="toc-nav"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#1-权限基本概述"><span class="toc-nav-text">1.权限基本概述</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#1-什么是权限？"><span class="toc-nav-text">1.什么是权限？</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#2-为什么要有权限？"><span class="toc-nav-text">2.为什么要有权限？</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#3-权限与用户之间的关系？"><span class="toc-nav-text">3.权限与用户之间的关系？</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#4-权限中的rwx分别代表什么含义？"><span class="toc-nav-text">4.权限中的rwx分别代表什么含义？</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#2-权限设置示例"><span class="toc-nav-text">2.权限设置示例</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#1-为什么要设定权限，我们又如何修改一个文件的权限"><span class="toc-nav-text">1.为什么要设定权限，我们又如何修改一个文件的权限?</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#2-使用chmod设定权限示例"><span class="toc-nav-text">2.使用chmod设定权限示例</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#3-权限设置案例"><span class="toc-nav-text">3.权限设置案例</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#3-权限设置案例-1"><span class="toc-nav-text">3.权限设置案例</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#4-属主属组设置"><span class="toc-nav-text">4.属主属组设置</span></a></li></ol>
    
  </div>
</aside>
  
  <!-- Catalog END -->
</main>

<script>
  (function () {
    var url = 'http://www.liuqingzheng.top/linux/入门到精通/07-Linux基本权限/';
    var banner = ''
    if (banner !== '' && banner !== 'undefined' && banner !== 'null') {
      $('#article-banner').css({
        'background-image': 'url(' + banner + ')'
      })
    } else {
      $('#article-banner').geopattern(url)
    }
    $('.header').removeClass('fixed-header')

    // error image
    $(".markdown-content img").on('error', function() {
      $(this).attr('src', 'http://file.muyutech.com/error-img.png')
      $(this).css({
        'cursor': 'default'
      })
    })

    // zoom image
    $(".markdown-content img").on('click', function() {
      var src = $(this).attr('src')
      if (src !== 'http://file.muyutech.com/error-img.png') {
        var imageW = $(this).width()
        var imageH = $(this).height()

        var zoom = ($(window).width() * 0.95 / imageW).toFixed(2)
        zoom = zoom < 1 ? 1 : zoom
        zoom = zoom > 2 ? 2 : zoom
        var transY = (($(window).height() - imageH) / 2).toFixed(2)

        $('body').append('<div class="image-view-wrap"><div class="image-view-inner"><img src="'+ src +'" /></div></div>')
        $('.image-view-wrap').addClass('wrap-active')
        $('.image-view-wrap img').css({
          'width': `${imageW}`,
          'transform': `translate3d(0, ${transY}px, 0) scale3d(${zoom}, ${zoom}, 1)`
        })
        $('html').css('overflow', 'hidden')

        $('.image-view-wrap').on('click', function() {
          $(this).remove()
          $('html').attr('style', '')
        })
      }
    })
  })();
</script>


  <script>
    var qr = new QRious({
      element: document.getElementById('share-qrcode'),
      value: document.location.href
    });
  </script>



  <script>
    var gitmentConfig = "liuqingzheng";
    if (gitmentConfig !== 'undefined') {
      var gitment = new Gitment({
        id: "linux/入门到精通/07-Linux基本权限",
        owner: "liuqingzheng",
        repo: "FuckBlog",
        oauth: {
          client_id: "32a4076431cf39d0ecea",
          client_secret: "94484bd79b3346a949acb2fda3c8a76ce16990c6"
        },
        theme: {
          render(state, instance) {
            const container = document.createElement('div')
            container.lang = "en-US"
            container.className = 'gitment-container gitment-root-container'
            container.appendChild(instance.renderHeader(state, instance))
            container.appendChild(instance.renderEditor(state, instance))
            container.appendChild(instance.renderComments(state, instance))
            container.appendChild(instance.renderFooter(state, instance))
            return container;
          }
        }
      })
      gitment.render(document.getElementById('comments'))
    }
  </script>




    <div class="scroll-top">
  <span class="arrow-icon"></span>
</div>
    <footer class="app-footer">
<!-- 不蒜子统计 -->
<span id="busuanzi_container_site_pv">
     本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
<span class="post-meta-divider">|</span>
<span id="busuanzi_container_site_uv" style='display:none'>
     本站访客数<span id="busuanzi_value_site_uv"></span>人
</span>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



  <p class="copyright">
    &copy; 2021 | Proudly powered by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank">小猿取经</a>
    <br>
    Theme by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank" rel="noopener">小猿取经</a>
  </p>
</footer>

<script>
  function async(u, c) {
    var d = document, t = 'script',
      o = d.createElement(t),
      s = d.getElementsByTagName(t)[0];
    o.src = u;
    if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
    s.parentNode.insertBefore(o, s);
  }
</script>
<script>
  async("//cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js", function(){
    FastClick.attach(document.body);
  })
</script>

<script>
  var hasLine = 'true';
  async("//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js", function(){
    $('figure pre').each(function(i, block) {
      var figure = $(this).parents('figure');
      if (hasLine === 'false') {
        figure.find('.gutter').hide();
      }
      var lang = figure.attr('class').split(' ')[1] || 'code';
      var codeHtml = $(this).html();
      var codeTag = document.createElement('code');
      codeTag.className = lang;
      codeTag.innerHTML = codeHtml;
      $(this).attr('class', '').empty().html(codeTag);
      figure.attr('data-lang', lang.toUpperCase());
      hljs.highlightBlock(block);
    });
  })
</script>





<!-- Baidu Tongji -->

<script>
    var _baId = 'c5fd96eee1193585be191f318c3fa725';
    // Originial
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?" + _baId;
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
</script>


<script src="/js/script.js"></script>


<script src="/js/search.js"></script>


<script src="/js/load.js"></script>



  <span class="local-search local-search-google local-search-plugin" style="right: 50px;top: 70px;;position:absolute;z-index:2;">
      <input type="search" placeholder="站内搜索" id="local-search-input" class="local-search-input-cls" style="">
      <div id="local-search-result" class="local-search-result-cls"></div>
  </span>


  </body>
</html>